<?php
include("functions.php");
include("libs/smarty.class.php");

$smarty = new Smarty();

$title = "Rejestracja";
$smarty->assign("title",$title);

$faculties = getRows("*","faculty");
$specializations = array();

if($_POST['id']){
    $faculty_id=$_POST['id'];
    $sql = mysql_query("SELECT s.id,s.name FROM faculty f, specializations s
                    WHERE (s.id_faculty = '$faculty_id' AND s.id_faculty=f.id)");
    while($row = mysql_fetch_assoc($sql)){
        $specializations[] = $row;
    }
}
if($_POST){

    foreach($_POST as $key => $value){
        $data[$key] = $value;
    }

    if($_POST['choose'] == 'student'){
        echo addStudent($data);
    }
    else{
        echo addCompany($data);
    }
}
$smarty->assign("specializations",$specializations);
$smarty->assign("faculties",$faculties);
$smarty->display('register.tpl');
?>
